How can I update the "Important" field, which is stored in a subcollection?

import firebaseApp from "../../utils/firebase";
import { getFirestore, doc, updateDoc } from "firebase/firestore";
const firestoreDB = getFirestore(firebaseApp);
const USER_DATA = "UsersData";
const TASKS = "Tasks";
const updateImportantValue = async (userID, newValue) => {
try {
const docRef = doc(
firestoreDB,
USER_DATA,
userID,
TASKS,
"EyS9R8dHV3EU3WS2PeQo"
);
await updateDoc(docRef, {
important: newValue,
});
console.log(firestoreDB);
console.log(USER_DATA);
console.log(userID);
console.log(TASKS);
console.log(newValue);
console.log("updateImportantValue - success");
} catch (error) {
console.log(error);
}
};
I tried this way but it throws me an error:
TypeError: n.indexOf is not a function
at Function.fromString (index.esm2017.js:1084:1)
at ia (index.esm2017.js:16166:1)
at updateImportantValue (updateImportantValue.js:9:1)
at removeImportant (useTask.js:76:1)
at importantButton (TaskData.js:16:1)
at onClick (TaskData.js:37:1)
at HTMLUnknownElement.callCallback (react-dom.development.js:3945:1)
at Object.invokeGuardedCallbackDev (react-dom.development.js:3994:1)
at invokeGuardedCallback (react-dom.development.js:4056:1)
at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:4070:1)
Update
Update, I was not receiving the User ID correctly. I corrected the error and the console indicates that everything was correct, but in firestore the document does not undergo any change, the "important" field remains the same.